package com.syedu.day05.homework;

/**
 * description：递归实现杨辉三角形
 * @author Administrator
 * @date 2022/3/11 9:05
 */
public class YangHui {
    public static void main(String[] args) {
        for (int i = 1; i <= 6; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(getData(i, j) + "\t");
            }
            System.out.println();
        }
    }

    /**
     * 写一个方法,获取任意行任意列上杨辉三角形的值
     */
    public static int getData(int row, int col) {
        if (row == 1 || col == 1 || row == col) {
            return 1;
        }
        return getData(row - 1, col) + getData(row - 1, col - 1);
    }
}